<?php

require_once 'Date.php';
require_once 'Db.php';

class Test {


    public static function assertCoin($a) {
        $db=DB::getInstance();
        $sql = 'select miso_id from hd_monedasiso where miso_Cod_elite is not null;';
        $result = $db->getall($sql);
        printArray($result);

        $result = $a > 0;
        self::printTest($result);
        return $result;
    }

    public static function assertPositive($a) {
        $result = $a > 0;
        self::printTest($result);
        return $result;
    }

    public static function assertInt($a) {
        $result = is_int($a);
        self::printTest($result);
        return $result;
    }

    public static function assertDate($a) {
        $result = Date::checkdate($a);
        self::printTest($result);
        return $result;
    }

    public static function assertEqual($a, $b) {
        $result = ($a == $b);
        self::printTest($result);
        return $result;
    }

    public static function assertFalse($a) {
        $result = ($a == false);
        self::printTest($result);
        return $result;
    }

    public static function assertTrue($a) {
        $result = ($a == true);
        self::printTest($result);
        return $result;
    }

    private static function printTest($result) {
        if ($result) {
            echo '<div style="color:green">ok</div>';
        } else {
            echo '<div style="color:red">ko</div>';
        }
    }

}